// search 模块仓库 vuex~
import {requestSearchInfo} from "@/api/index.js";
const actions = {
  // 通过API里面的接口函数调用，向服务器发请求，获取数据
  async searchInfo({commit}, value) {
    let xml = await requestSearchInfo(value); 
    // console.log(xml)   
    if(xml.data.code) {
      commit("SEARCHINFO", xml.data);
    }    
  },
  
};
const mutations = {  
  SEARCHINFO(state, value) {
    state.searchInfo = value;    
  },
  
};
const state = {
  searchInfo: null,
};

const getters = {
  // 请求参数
  goodsList(state) {
    return state.searchInfo ? state.searchInfo.data.goodsList : [];
  },
  // 品牌
  trademarkList(state) {
    return state.searchInfo ? state.searchInfo.data.trademarkList : [];
  },
  // 信息
  attrsList(state) {
    return state.searchInfo ? state.searchInfo.data.attrsList : [];
  },
  // 数量
  totalList(state) {
    return state.searchInfo ? state.searchInfo.data.total : [];
  }
};
export default {
  actions,
  mutations,
  state,
  getters,
}